<%@ page language="java" import="dao.*" pageEncoding="UTF-8" %>
<%@ page language="java" import="java.util.*" %>
<%@page import="util.*" %>


<%@ include file="head.jsp" %>
<script src="js/datepicker/WdatePicker.js"></script>

<div style="padding: 10px">
    <%
        //------------------------------------------------
        String orderby = util.Request.get("order", "id");  // 获取搜索框中的排序字段、默认为发布时间
        String sort = util.Request.get("sort", "desc");   // 获取搜索框中的排序类型、默认为倒序

        String where = " 1=1 ";   // 防止sql 搜索条件为： where and a=b 这样的错误
        where += " AND xiadanren='" + request.getSession().getAttribute("username") + "' "; //  设置xiadanren为当前登录用户


// 以下是检测搜索框中是否填写了或者选择了什么，则写入sql 语句中


        if (request.getParameter("shangpinxinxiid") != null && !"".equals(request.getParameter("shangpinxinxiid"))) {
            where += " AND shangpinxinxiid='" + request.getParameter("shangpinxinxiid") + "' ";

        }
        if (request.getParameter("shangpinbianhao") != null && !"".equals(request.getParameter("shangpinbianhao"))) {
            where += " AND shangpinbianhao LIKE '%" + request.getParameter("shangpinbianhao") + "%'";
        }
        if (request.getParameter("shangpinmingcheng") != null && !"".equals(request.getParameter("shangpinmingcheng"))) {
            where += " AND shangpinmingcheng LIKE '%" + request.getParameter("shangpinmingcheng") + "%'";
        }
        if (request.getParameter("shangpinfenlei") != null && !"".equals(request.getParameter("shangpinfenlei"))) {
            where += " AND shangpinfenlei ='" + request.getParameter("shangpinfenlei") + "'";
        }
        if (request.getParameter("lianxidianhua") != null && !"".equals(request.getParameter("lianxidianhua"))) {
            where += " AND lianxidianhua LIKE '%" + request.getParameter("lianxidianhua") + "%'";
        }
        if (request.getParameter("jiaoyishijian_start") != null && !"".equals(request.getParameter("jiaoyishijian_start"))) {
            where += " AND jiaoyishijian >='" + request.getParameter("jiaoyishijian_start") + "' ";
        }
        if (request.getParameter("jiaoyishijian_end") != null && !"".equals(request.getParameter("jiaoyishijian_end"))) {
            where += " AND jiaoyishijian <='" + request.getParameter("jiaoyishijian_end") + "' ";
        }
        if (request.getParameter("jiaoyizhuangtai") != null && !"".equals(request.getParameter("jiaoyizhuangtai"))) {
            where += " AND jiaoyizhuangtai ='" + request.getParameter("jiaoyizhuangtai") + "'";
        }
        List<HashMap> list = Query.make("xiadan").where(where).order(orderby + " " + sort).page(15);

    %>


    <div class="panel panel-default">
        <div class="panel-heading">
        <span class="module-name">
            下单        </span>
            <span>列表</span>
        </div>
        <div class="panel-body">
            <div class="pa10 bg-warning">

            </div>


            <div class="">
                <table width="100%" border="1" class="table table-list table-bordered table-hover">
                    <thead>
                    <tr align="center">
                        <th width="60" data-field="item">序号</th>
                        <th> 商品编号</th>
                        <th> 商品名称</th>
                        <th> 售价</th>
                        <th> 商品分类</th>
                        <th> 发布人</th>
                        <th> 联系电话</th>
                        <th> 交易时间</th>
                        <th> 交易地点</th>

                        <th> 下单人</th>
                        <th width="130" data-field="iszf">是否支付</th>


                    </tr>
                    </thead>
                    <tbody>
                    <%
                        int i = 0;
                        for (HashMap map : list) {
                            i++;
                    %>
                    <tr id="<%= map.get("id") %>" pid="">
                        <td width="30" align="center">
                            <label>
                                <%= i %>
                            </label>
                        </td>
                        <td><%= map.get("shangpinbianhao") %>
                        </td>
                        <td><%= map.get("shangpinmingcheng") %>
                        </td>
                        <td><%= map.get("shoujia") %>
                        </td>
                        <td><%
                            HashMap mapshangpinfenlei11 = new CommDAO().find("SELECT fenleimingcheng FROM shangpinfenlei where id='" + map.get("shangpinfenlei") + "'");
                        %><%= mapshangpinfenlei11.get("fenleimingcheng") %>
                        </td>
                        <td><%= map.get("faburen") %>
                        </td>
                        <td><%= map.get("lianxidianhua") %>
                        </td>
                        <td><%= map.get("jiaoyishijian") %>
                        </td>
                        <td><%= map.get("jiaoyididian") %>
                        </td>

                        <td><%= map.get("xiadanren") %>
                        </td>
                        <td>
                            <%= map.get("iszf") %>
                            <% if ("否".equals(map.get("iszf"))) { %>
                            <a href="zhifu/index.jsp?id=<%= map.get("id") %>&biao=xiadan">
                                去支付
                            </a>
                            <% } %>
                        </td>





                            <!--qiatnalijne-->
                        </td>
                    </tr>
                    <% } %>
                    </tbody>
                </table>
            </div>

            ${page.info}


        </div>


    </div>


</div>
<%@ include file="foot.jsp" %>
